package com.hongxun.modules.bss.service.impl;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.hongxun.modules.bss.dao.APOtherDao;
import com.hongxun.modules.bss.entity.APOtherEntity;
import com.hongxun.modules.bss.service.APOtherService;



@Service("aPOtherService")
public class APOtherServiceImpl implements APOtherService {
	@Autowired
	private APOtherDao aPOtherDao;
	
	@Override
	public APOtherEntity queryObject(String guid){
		return aPOtherDao.queryObject(guid);
	}
	
	@Override
	public List<APOtherEntity> queryList(Map<String, Object> map){
		return aPOtherDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return aPOtherDao.queryTotal(map);
	}
	
	@Override
	public void save(APOtherEntity aPOther){
		if(aPOther.getGuid()==null||aPOther.getGuid().equals("")) {

			aPOther.setGuid(UUID.randomUUID().toString());
		}
		aPOtherDao.save(aPOther);
	}
	
	@Override
	public void update(APOtherEntity aPOther){
		aPOtherDao.update(aPOther);
	}
	
	@Override
	public void delete(String guid){
		aPOtherDao.delete(guid);
	}
	
	@Override
	public void deleteBatch(String[] guids){
		aPOtherDao.deleteBatch(guids);
	}

	@Override
	public void insertOrReplaceOrDelete(List<APOtherEntity> entities) {
		for (APOtherEntity d : entities) {
			if (d.getPODatastate().equals("删除")) {
				aPOtherDao.delete(d.getGuid());
			} else {
				APOtherEntity apOtherEntity = aPOtherDao.queryObject(d.getGuid());
				if (apOtherEntity == null) {
					aPOtherDao.save(d);
				} else {
					aPOtherDao.update(d);
				}
			}
		}
	}
}
